# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


# useful for handling different item types with a single interface
from itemadapter import ItemAdapter


class ProjectdemoPipeline:
    def process_item(self, item, spider):
        """
        这个是抓取到具体数据后(需要有item返回),做处理的逻辑.
        :param item: spider抓取的数据,传递过来
        :param spider:
        :return:
        """
        # print(item['bookname'])

        with open('record.txt','a',encoding='utf-8') as fw:
            fw.write(item['bookname'] + '\t' + item['author'] + '\t' + item['score'] + '\n')
        return item
